home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / gametp20.zip / VGAKERN.INT < prev    next >
Text File  |  1992-11-06  |  26KB  |  762 lines

  1. Unit VgaKern;
  2.  
  3. { VgaKern version 3.6 Copyright (C) 1992 Scott D. Ramsay    }
  4. {                                  ramsays@access.digex.com }
  5.  
  6. {   This unit is specifically for Mode 13h (320x200x256).  It is a    }
  7. { lot faster than using the BGI drivers (VGA256.BGI).  Majority of    }
  8. { the code is written using BASM.  This will work on 286 machines or  }
  9. { higher. "I don't know about the P5 chip though." ;)                 }
  10. {   This is the raw unit of the lib.  Most of the basic low level     }
  11. { routines are here.                                                  }
  12. {   VGAKERN.TPU can be used freely in commerical and non-commerical   }
  13. { programs.  As long as you don't give yourself credit for writing    }
  14. { this portion of the code.  When distributing it (free only), please }
  15. { include all files and samples so others may enjoy using the code.   }
  16. { Enjoy.                                                              }
  17.  
  18. { Please bear with my comments.  I'm not a tech-writer.  You're more  }
  19. { than welcome to modify the comments in this file for people to      }
  20. { understand. "Except for my name."  :)                               }
  21.  
  22. { Changes from 3.4:                                                   }
  23. {    New procedure:    ColorsChange(var color:rgblist;filter:rgbtype);}
  24. {        Changes a palette based on the filter                        }
  25.  
  26. Interface
  27.  
  28. const
  29.   VidSet     : boolean = true;       { When set to FALSE, OPENMODE() does  }
  30.                                      { clear the vga screen to black       }
  31.                                      {  e.g.  ah=$93 instead of ah=$13     }
  32.                                      { See dos ref. for the set of HI-bit  }
  33.   MaxPages   = 8;                    { Maxium virtual pages allowed        }
  34.   WinMinX    : word = 0;             { WinMin% sets the boundry for CLINE  }
  35.   WinMinY    : word = 0;             {  This is the only function that     }
  36.   WinMaxX    : word = 319;           {  does any clipping. (Clipping slows }
  37.   WinMaxY    : word = 199;           {  slows functions)                   }
  38.  
  39. type
  40.  
  41. { RGBType/RGBlist handles the color palette }
  42.  
  43.   RGBType    = record
  44.                  red,green,blue : byte;
  45.                end;
  46.   RGBlist    = array[0..255] of RGBType;
  47.  
  48. { Same as then record declared in TVISION's OBJECTS unit }
  49.   PtrRec     = record
  50.                  ofs,seg : word;
  51.                end;
  52. var
  53.   PrevMode,                                      { previous }
  54.   crpg          : byte;                          { current active page  }
  55.   scnseg,scnofs : word;                          { current page address }
  56.   pages         : array[1..MaxPages] of pointer; { page pointers }
  57.   thdmat        : set of byte;                   { set for mattevsp }
  58.   vspcnt,                                        { vsp last load count }
  59.   maxpage       : word;                          { pages used }
  60.   zdc           : RGBlist;                       { all black palette }
  61.  
  62. { See Implementation section for description of functions }
  63.  
  64. procedure ColorsChange(var color:rgblist;filter:rgbtype);
  65. function LoadVSP(fn:string;var buff):integer;
  66. procedure MatteVsp(var from,too);
  67. procedure VSinc;
  68. procedure SetDefaultColors;
  69. procedure Switch(var a,b:integer);
  70. procedure Parse(var x,y:integer);
  71. function BuffSize(width,height:integer):word;
  72. function ImageSize(var image):word;
  73. procedure ImageDims(var image;var width,height:integer);
  74. procedure SetPtr(var i:PtrRec;var buff);
  75. function pt(x,y:integer):word;
  76. procedure OpenMode(npages:byte);
  77. function Point(x,y:integer;pg:byte):byte;
  78. procedure Pset(x,y:integer;n:byte);
  79. procedure fPcopy(var from,too);
  80. procedure Pcopy(from,too:byte);
  81. procedure FastMatte(x1,y1,x2,y2:integer;var from,too);
  82. procedure SwapMatte(x1,y1,x2,y2:integer;from,too:byte);
  83. procedure Matte(x1,y1,x2,y2:integer;from,too:byte);
  84. procedure Line(x1,y1,x2,y2:integer;n:byte);
  85. procedure Bar(x1,y1,x2,y2:integer;n:byte);
  86. procedure Rectangle(x1,y1,x2,y2:integer;n:byte);
  87. procedure Circle(x1,y1,r:integer;n:byte);
  88. procedure Ellipse(xc,yc,a0,b0:integer;c:byte);
  89. procedure fBitDraw(x,y:word;var buff);
  90. procedure Cls(n:byte);
  91. procedure CloseMode;
  92. procedure FastGet(x1,y1,x2,y2:integer;var image);
  93. procedure GetPic(x1,y1,x2,y2:integer;var image);
  94. procedure FastPut(x1,y1:integer;var image);
  95. procedure PutPic(x1,y1:integer;var image;rmw:byte);
  96. procedure SetPageActive(page:byte);
  97. procedure GetColor(num:byte;var red,green,blue:byte);
  98. procedure SetColor(num,red,green,blue:byte);
  99. procedure fSetColors(var colors);
  100. procedure fGetColors(var colors);
  101. procedure FadeIn(steps:word;var color1,color2);
  102. procedure FadeOut(steps:word;var color1,color2);
  103. function LoadColors(filename:string;var colors;count:integer):integer;
  104. function SaveColors(filename:string;var colors;count:integer):integer;
  105. procedure Paint(x,y:integer;n:byte);
  106. procedure CopyTo(x1,y1,x2,y2,x,y:integer;from,too:byte);
  107. procedure BitDraw(x,y:integer;var image,matte);
  108. procedure BitErase(x,y:integer;page:byte;var matte);
  109. procedure DispLayer(x,y:integer;var pic,mat,virt;plv:byte);
  110. procedure EraseLayer(x,y:integer;bkpage:byte;var mat,virt;plv:byte);
  111. procedure DispVirt(x,y:integer;var mat,virt;plv:byte);
  112. procedure EraseVirt(x,y:integer;var mat,virt;plv:byte);
  113. procedure CopyVirt(x,y:integer;var mat,v1,v2;plv:byte);
  114. procedure DispSprite(x,y:integer;var pic,mat,virt;plv:byte);
  115. procedure EraseSprite(x,y:integer;var mat,v2;bkpage,plv:byte);
  116. function AnalyzeScreen:byte;
  117. procedure MemWrite(var source,dest;size:word;var off:longint);
  118. procedure MemRead(var source,dest;size:word;var off:longint);
  119. procedure FastWPut(x1,y1:integer;var image);
  120. procedure FastWMatte(x1,y1,x2,y2:integer;var from,too);
  121.  
  122. Implementation
  123.  
  124. (***********************************************************************)
  125. function LoadVSP(fn:string;var buff):integer;
  126.  
  127.   Loads a VSP (Vga SPrite) file.  The procedure automatically
  128.   allocates memory for the images onto the heap space
  129.  
  130.   fn:string     The VSP file name
  131.   buff          The location to place the sprites
  132.                 NOTE: buff must be of type POINTER
  133.                 or an array of pointers
  134.                 e.g.
  135.                    var
  136.                      sprite_1 : pointer;
  137.                      sprite_2 : array[1..sprites_in_file] of pointer;
  138.  
  139.    The format of a sprite file:
  140.  
  141. {       BYTE            SIZE   DESCRIPTION
  142.         0..1            word   width of sprite
  143.         2..3            word   height of sprite
  144.     4..(width*height+4) byte   pixel information
  145.          n              word   width of next sprite
  146.          n+2            word   height of next sprite
  147.                    .
  148.                    .
  149.                    .
  150.  }
  151.    example:
  152.  
  153.       const
  154.         sprites_in_file = 10;
  155.       var
  156.         list_sprite : array[1..sprites_in_file] of pointer;
  157.         a_sprite    : pointer;
  158.       begin
  159.         loadvsp('sprite01.vsp',list_sprite);
  160.         loadvsp('sprite02.vsp',a_sprite);
  161.         fastput(10,10,list_sprite[2]^);
  162.         fastput(100,100,a_sprite^);
  163.       end;
  164.  
  165. (***********************************************************************)
  166. procedure MatteVsp(var from,too);
  167.  
  168.   Creates a VSP matte,  the matte is used for identifying
  169.   transparent color in sprites using the set THDMAT for
  170.   the transparent colors.  The "too" sprite memory must
  171.   be allocated or a static array large enough to fit the
  172.   entire sprite.
  173.  
  174.           e.g
  175.             var
  176.               sprite1 : pointer;               { <- need to allocate }
  177.               sprite2 : array[1..260] of byte; { <- ready to use }
  178.  
  179.             getmem(sprite,BuffSize(16,16)); { allocate mem for 16x16 sprite }
  180.  
  181.  
  182.  
  183.     example:
  184.  
  185.        const
  186.          sprite_size = 1000;
  187.  
  188.        var
  189.          sprite,sprite_matte : pointer;
  190.          sprites             : array[0..1] of pointer;
  191.          mattesprite         : array[1..sprite_size] of byte;
  192.        begin
  193.            .
  194.            .
  195.            .
  196.          THDMAT := [0,4,5]; { Transparent colors for mattevsp are now 0,4,5 }
  197.          MatteVsp(sprite^,sprite_matte^);
  198.          MatteVsp(sprite[0]^,sprite[1]^);
  199.          THDMAT := [0];     { 0 is the only transparent color }
  200.          MatteVsp(sprite[0]^,mattesprite);
  201.  
  202.      }
  203.  
  204.  
  205. (***********************************************************************)
  206. procedure VSinc;
  207.  
  208.    Waits for VBI "Vertical Blanking Interval"
  209.  
  210. (***********************************************************************)
  211. procedure SetDefaultColors;
  212.  
  213.    Sets to the default palette.  Colors 0..15 are the default EGA colors
  214.    where 16..255 are different intensities of those colors
  215.  
  216.  
  217. (***********************************************************************)
  218. procedure Switch(var a,b:integer);
  219.  
  220.    Switches the values of A and B.  Quickly!
  221.  
  222.      a := a xor b;
  223.      b := a xor b;
  224.      a := a xor b;            { do the math, it works! }
  225.  
  226. (***********************************************************************)
  227. procedure Parse(var x,y:integer);
  228.  
  229.    Clips the values of X and Y to be in the range 0..319, 0..199
  230.      if x<0 then x := 0
  231.      else
  232.        if x>319
  233.          then x := 319;
  234.      if y<0 then y := 0
  235.        else
  236.          if y>199
  237.            then y := 199;
  238.  
  239. (***********************************************************************)
  240. function BuffSize(width,height:integer):word;
  241.  
  242.      Returns the bytes required to store a sprite of size
  243.        width, height.
  244.  
  245. (***********************************************************************)
  246. function ImageSize(var image):word;
  247.  
  248.     Returns the amount of memory the sprite uses. (in bytes)
  249.  
  250. (***********************************************************************)
  251. procedure ImageDims(var image;var width,height:integer);
  252.  
  253.    Returns the width and height of a sprite
  254.  
  255. (***********************************************************************)
  256. procedure SetPtr(var i:PtrRec;var buff);
  257.  
  258.    Sets the Segment and offset of buff to the i:PTRREC
  259. (***********************************************************************)
  260. function pt(x,y:integer):word;
  261.  
  262.    Calcuates the screen offset of x,y.
  263.  
  264.      example:
  265.  
  266.        const
  267.          x = 160;
  268.          y = 100;
  269.  
  270.          .
  271.          .
  272.          .
  273.        begin
  274.          mem[$A000:pt(x,y)] := 1; { Places a pixel of color 1 at (x,y) }
  275.        end;
  276.  
  277.  
  278. (***********************************************************************)
  279. procedure OpenMode(npages:byte);
  280.  
  281.    Sets to mode 13h, Initalizes variables,  Allocates virtual pages,
  282.    and sets default palette.  (The first call you should do before
  283.    using the other functions.
  284.  
  285.    npages:byte;   { The number of pages to allocate }
  286.  
  287.    example:
  288.  
  289.        openmode(3);  { allocates 2 virtual pages to the heap }
  290.                      { page 1 is always $A000:0              }
  291.  
  292.        You must copy pages 2..n to page 1 to view.  The visual
  293.        page is always page 1.
  294.  
  295. (***********************************************************************)
  296. function Point(x,y:integer;pg:byte):byte;
  297.  
  298.   Returns the pixel value at (X,Y) on page (PG)
  299.  
  300. (***********************************************************************)
  301. procedure Pset(x,y:integer;n:byte);
  302.  
  303.   Sets a pixel value on the current page of (N) at (X,Y)
  304.  
  305. (***********************************************************************)
  306. procedure fPcopy(var from,too);
  307.  
  308.   Copies a page to another page, Fast.
  309.  
  310.    example:
  311.  
  312.      fPcopy(pages[1]^,pages[2]^); { copies the contents of page 1 to page 2 }
  313.  
  314.    The untyped parameters allows for user created virtual pages.  Such
  315.    at EMS memory.  e.g.    fPcopy(pages[2]^,mem[EMSsegment,0]);
  316.  
  317.  
  318. (***********************************************************************)
  319. procedure Pcopy(from,too:byte);
  320.  
  321.   Copies a page to another page.
  322.  
  323.      Pcopy(2,4);  { Copies the contents of page 1 to page 4 }
  324.  
  325. (***********************************************************************)
  326. procedure FastMatte(x1,y1,x2,y2:integer;var from,too);
  327.  
  328.   Copies a rectanglar region (x1,y1,x2,y2) at FROM to TOO.
  329.  
  330.     example:
  331.  
  332.        FastMatte(10,10,100,100,pages[1]^,pages[2]^);
  333.  
  334. (***********************************************************************)
  335. procedure SwapMatte(x1,y1,x2,y2:integer;page1,page2:byte);
  336.  
  337.    Switches a rectanglar region (x1,y1,x2,y2). Not blinding fast.
  338.  
  339.      example:
  340.  
  341.         SwapMatte(0,0,319,199,4,2); { exchanges contents of page 4, page 2
  342.  
  343. (***********************************************************************)
  344. procedure Matte(x1,y1,x2,y2:integer;from,too:byte);
  345.  
  346.   Same a FastMatte.  Slower.
  347.  
  348.     example:
  349.  
  350.        Matte(100,100,120,145,1,2);
  351.  
  352. (***********************************************************************)
  353. procedure Line(x1,y1,x2,y2:integer;n:byte);
  354.  
  355.   Draws a line on the current page.  Alot faster than BGI drivers.
  356.  
  357. (***********************************************************************)
  358. procedure Bar(x1,y1,x2,y2:integer;n:byte);
  359.  
  360.   Draws a filled rectangle on the current page
  361.  
  362. (***********************************************************************)
  363. procedure Rectangle(x1,y1,x2,y2:integer;n:byte);
  364.  
  365.   Draws a rectangle on the current page
  366.  
  367. (***********************************************************************)
  368. procedure Circle(x1,y1,r:integer;n:byte);
  369.  
  370.   Draws a circle with a radius of R and color N on the current page
  371.  
  372. (***********************************************************************)
  373. procedure Ellipse(xc,yc,a0,b0:integer;c:byte);
  374.  
  375.   Draws an ellipse with horiz radius of a0 and vertical radius of b0
  376.  
  377. (***********************************************************************)
  378. procedure fBitDraw(x,y:word;var buff);
  379.  
  380.   Draws a sprite on the current page with color 0 being transparent. Fast.
  381.  
  382. (***********************************************************************)
  383. procedure Cls(n:byte);
  384.  
  385.   Clear the current page to color (N)
  386.  
  387. (***********************************************************************)
  388. procedure CloseMode;
  389.  
  390.   Deallocates virtual pages and restores the display mode.
  391.  
  392. (***********************************************************************)
  393. procedure FastGet(x1,y1,x2,y2:integer;var image);
  394.  
  395.   Gets a sprite from the current page at the region (x1,y1,x2,y2) faster
  396.   than GetPic.
  397.  
  398.    example:
  399.  
  400.      var
  401.        sprite : pointer;
  402.        .
  403.        .
  404.        .
  405.      FastGet(10,10,24,26,sprite^);
  406.  
  407. (***********************************************************************)
  408. procedure GetPic(x1,y1,x2,y2:integer;var image);
  409.  
  410.   Same as FastGet.
  411.  
  412. (***********************************************************************)
  413. procedure FastPut(x1,y1:integer;var image);
  414.  
  415.   Puts a sprite onto the current page. Fast.  With no transparency.
  416.  
  417.      example:
  418.  
  419.         var
  420.           sprite : array[0..100] of byte;
  421.           listsprite : array[0..2] of pointer;
  422.           .
  423.           .
  424.           .
  425.         FastPut(10,10,sprite);
  426.         FastPut(20,20,listsprite[2]^);
  427.  
  428. (***********************************************************************)
  429. procedure PutPic(x1,y1:integer;var image;rmw:byte);
  430.  
  431.   Puts a sprite onto the current page.
  432.     values of RMW
  433.       0  = MOV
  434.       1  = XOR
  435.       2  = OR
  436.       3  = AND
  437.       4  = NOT
  438.     The above values are the same as XORput,NormPut ... defined in
  439.     the unit GRAPH.TPU
  440.  
  441. (***********************************************************************)
  442. procedure SetPageActive(page:byte);
  443.  
  444.   Changes the active page specified by (PAGE).  Updates the values
  445.   of SCNSEG, SCNOFS.
  446.  
  447.     example:
  448.  
  449.         SetPageActive(1);  { SCNSEG = $A000, SCNOFS = 0 }
  450.  
  451.   User defined pages can be set by modifing SCNSEG and SCNOFS directly.
  452.      e.g.
  453.           var
  454.              ascreen : pointer;
  455.  
  456.              .
  457.              .
  458.              .
  459.           getmem(ascreen,64000);  { screen size = 64000 bytes }
  460.           SCNSEG := seg(ascreen^);
  461.           SCNOFS := ofs(ascreen^);
  462.           line(0,0,319,199,4);     { draws a line on ascreen }
  463.  
  464. (***********************************************************************)
  465. procedure GetColor(num:byte;var red,green,blue:byte);
  466.  
  467.   Returns the red, green, blue values of color (num)
  468.  
  469. (***********************************************************************)
  470. procedure SetColor(num,red,green,blue:byte);
  471.  
  472.   Sets the red, green, blue values of color (num)
  473.  
  474. (***********************************************************************)
  475. procedure fSetColors(var colors);
  476.  
  477.   Sets the entire palette. (With out flicker)
  478.  
  479.   colors is usually variable of type RGBlist
  480.  
  481. (***********************************************************************)
  482. procedure fGetColors(var colors);
  483.  
  484.   Gets the current color palette.
  485.  
  486. (***********************************************************************)
  487. procedure FadeIn(steps:word;var color1,color2);
  488.  
  489.   Fades in the current palette from color1 to color2 in (STEPS) steps.
  490.  
  491.   example:
  492.  
  493.       var
  494.         MyPalette : RGBlist;
  495.           .
  496.           .
  497.           .
  498.  
  499.       LoadColors('colors.pal',MyPalette,256);
  500.       FSetColors(zdc);   { black out the palette.  ZDC defined in unit }
  501.       FadeIn(70,zdc,MyPalette);
  502.  
  503. (***********************************************************************)
  504. procedure FadeOut(steps:word;var color1,color2);
  505.  
  506.   Fades out the current palette from color2 to color1 in (STEPS) steps.
  507.  
  508.   example:
  509.  
  510.       var
  511.         MyPalette : RGBlist;
  512.           .
  513.           .
  514.           .
  515.  
  516.       LoadColors('colors.pal',MyPalette,256);
  517.       FSetColors(MyPalette);
  518.  
  519.           .
  520.           .
  521.           .
  522.  
  523.       FadeOut(70,zdc,MyPalette);   { Fades the screen to black }
  524.  
  525. (***********************************************************************)
  526. function LoadColors(filename:string;var colors;count:integer):integer;
  527.  
  528.    Loads a list of RGBtypes.
  529.      filename:string  The palette file.
  530.      colors           Location to store the palette
  531.      count            Number of colors to read
  532.  
  533.    example:
  534.  
  535.      LoadColors('colors.pal',MyPalette,256);
  536.      FSetColors(MyPalette);
  537.  
  538. (***********************************************************************)
  539. function SaveColors(filename:string;var colors;count:integer):integer;
  540.  
  541.    Saves a list of RGBtypes.
  542.      filename:string  The palette file.
  543.      colors           palette to save
  544.      count            Number of colors to save
  545.  
  546.    example:
  547.  
  548.      SaveColor('black.pal',zdc,256);
  549.  
  550. (***********************************************************************)
  551. procedure Paint(x,y:integer;n:byte);
  552.  
  553.   Does a flood fill at (x,y) with color n.  Changes only
  554.   the surrounding region at the color (x,y).  Slow, my own
  555.   coding, but it works.
  556.  
  557. (***********************************************************************)
  558. procedure CopyTo(x1,y1,x2,y2,x,y:integer;from,too:byte);
  559.  
  560.   Copies a rectangular region (x1,y1,x2,y2) to (x,y) (top,left corner)
  561.  
  562.   from,too indicates page number.
  563.  
  564.   Does check for overlapping regions if FROM and TOO are the same page.
  565.   (I hate checking code.  Slows things down. Write the program to
  566.    avoid overlapping.  "Just my 2cents" sorry.)
  567.  
  568. (***********************************************************************)
  569. procedure BitDraw(x,y:integer;var image,matte);
  570.  
  571.   Puts a sprite, on the screen transparent areas are specified
  572.   by the matte sprite.  Usefull for images that change transparency.
  573.   (The imgage doesn't change, only the matte);
  574.  
  575.   The how BitDraw works:
  576.      Checks the each pixel in "matte". If the pixel value in
  577.     matte is non-zero, then the corresponding pixel in "image"
  578.     is drawn onto the current page.
  579.  
  580.   NOTE: the image and matte sprites should be the same size.
  581.  
  582.   See also:  MatteVsp, DispLayer
  583.  
  584. (***********************************************************************)
  585. procedure BitErase(x,y:integer;page:byte;var matte);
  586.  
  587.   Erases the region on the current page by the region on (page) at X,Y.
  588.  
  589.   example:
  590.  
  591.       SetActivePage(1);
  592.       BitDraw(x,y,ball_sprite^,ball_matte^);
  593.       BitErase(x,y,2,ball_matte^);
  594.  
  595.       { page 2 can be the background, BitErase erases only the
  596.         areas affected by the BitDraw }
  597.  
  598. (***********************************************************************)
  599. procedure DispLayer(x,y:integer;var pic,mat,virt;plv:byte);
  600.  
  601.    Displays a Sprite (pic) and its matte (mat) on the current page.
  602.     Based on the sprites level.  (plv) is the sprite layer number. (virt)
  603.     virtual page which keeps track of "DispLayer" sprites on screen.
  604.  
  605.    Think of the display having 256 layers.  Layer 0 is furthest back and
  606.     layer 255 is the top layer.  For example, a sprite "Displayer" with
  607.     plv=4 will only overwrite sprites that have been written with a plv
  608.     value less than 4.  Sprites greater than 4 will be unaffected.
  609.  
  610.    The how DispLayer works:
  611.       Functions the same as BitDraw, except that it also checks the
  612.       screen location on the "virt" page.  If that pixel value is less
  613.       than the "plv" value, then the pixel is drawn.
  614.  
  615.    Use the "DispLayer" function with DispVirt to update the virtual page.
  616.  
  617.    See sample programs for use of this.  (I can't explain it very well, huh)
  618.  
  619.    example:
  620.                                       
  621.      DispLayer(x,y,sprite^,sprite_matte^,pages[2]^,4);
  622.                                       { Draws the sprite at layer 4 }
  623.                                       
  624.      DispVirt(x,y,sprite_matte^,pages[2]^,plv);
  625.                                       { Updates the virtual page }
  626.  
  627.    See Also:
  628.        BitDraw, BitErase, EraseLayer
  629.  
  630. (***********************************************************************)
  631. procedure EraseLayer(x,y:integer;bkpage:byte;var mat,virt;plv:byte);
  632.  
  633.    Erases a Sprite on the current page.
  634.  
  635.    x,y    : coordinates to place the sprite
  636.    bkpage : the background page to write to the current screen.
  637.    mat    : the sprite matte
  638.    plv    : sprite value
  639.  
  640.    Functionally the same as BitErase.  Except that the pixel value
  641.     at (virt) must less than equal to (plv)
  642.  
  643. (***********************************************************************)
  644. procedure DispVirt(x,y:integer;var mat,virt;plv:byte);
  645.  
  646.    Updates the (virt) "virtual" page.
  647.  
  648.    See EraseLayer, BitDraw, BitErase, DispLayer
  649.  
  650. (***********************************************************************)
  651. procedure EraseVirt(x,y:integer;var mat,virt;plv:byte);
  652.  
  653.    Erases the (virt) "virtual" page.
  654.  
  655.    See EraseLayer, BitDraw, BitErase, DispLayer
  656.  
  657. (***********************************************************************)
  658. procedure CopyVirt(x,y:integer;var mat,v1,v2;plv:byte);
  659.  
  660.   Copies the (plv) on page (v1) to (v2).
  661.  
  662.   Example:
  663.  
  664.      CopyVirt(x,y,sprite_mat^,pages[2]^,pages[3]^,4);
  665.  
  666. (***********************************************************************)
  667. procedure DispSprite(x,y:integer;var pic,mat,virt;plv:byte);
  668.  
  669.     Calls DispLayer(x,y,pic,mat,virt,plv); and
  670.     Calls DispVirt(x,y,mat,virt,plv);
  671.  
  672. (***********************************************************************)
  673. procedure EraseSprite(x,y:integer;var mat,v2;bkpage,plv:byte);
  674.  
  675.     Calls EraseVirt(x,y,mat,virt,plv); and
  676.     Calls EraseLayer(x,y,bkpage,mat,virt,plv);
  677.  
  678. (***********************************************************************)
  679. function AnalyzeScreen:byte;
  680.  
  681.    Returns the color number that is most used on the screen.
  682.  
  683.    Used by SavePTR in unit IMAGING.TPU
  684.  
  685. (***********************************************************************)
  686. procedure MemWrite(var source,dest;size:word;var off:longint);
  687.  
  688.    Copies a block of memory from "source" to "dest" of size "size".
  689.  
  690.    off: is the starting offset of "dest".  and
  691.      returns (off+size).  The next byte(s) to be read.
  692.  
  693.  
  694. (***********************************************************************)
  695. procedure MemRead(var source,dest;size:word;var off:longint);
  696.  
  697.    Same as MemWrite.  Except  "off" specifies the starting
  698.      offset of "source"
  699.  
  700. (***********************************************************************)
  701. procedure FastWPut(x1,y1:integer;var image);
  702.  
  703.    Same as FastPut.  But moves WORDS, instead of BYTES.
  704.     note: Make sure the width of the sprite is an even value.
  705.  
  706. (***********************************************************************)
  707. procedure FastWMatte(x1,y1,x2,y2:integer;var from,too);
  708.  
  709.    Same as FastMatte.  But moves WORDS instead of BYTES.
  710.    note: Make sure that (x2-x1)+1 is an even value.
  711.  
  712. (***********************************************************************)
  713. procedure ColorsChange(var color:rgblist;filter:rgbtype);
  714.  
  715.          Changes a palette based on the filter
  716.  
  717.    For example:  To change a palette to gray scale.
  718.  
  719.        const
  720.          GrayColor : RGBtype =
  721.                      (red:63;green:63;blue:63);
  722.        var
  723.          MyColors,
  724.          MyPalette : RGBlist;
  725.          DYellow   : RGBtype;
  726.             .
  727.             .
  728.             .
  729.          fsetcolor(MyPalette);   { My Color palette }
  730.          ColorsChange(MyPalette,GrayColor);
  731.          fsetcolor(MyPalette);   { My color palette is now gray scale }
  732.  
  733.        To make a dark yellow color filter:
  734.  
  735.           DYellow.red := 43;
  736.           DYellow.green := 30;
  737.           DYellow.blue := 4;
  738.  
  739.           ColorsChange(MyColors,DYellow);
  740.  
  741. (***********************************************************************)
  742.   As you will notice.   Some functions are similar. Such as:
  743.  
  744.       PUTPIC, FASTPUT, FASTWPUT
  745.       MATTE, FASTMATTE, FASTWMATTE
  746.  
  747.   This unit is a result of alot of revisions.  Notice it is version 3.5b
  748.   eventhough this is it first public release.
  749.  
  750.   I just kept the older versions of the functions in for my own
  751.    compatiblity.  "Lucky for Turbo's Smart Linking.  ;)"
  752.  
  753.  
  754. If you have any problems, e-mail at:
  755.  
  756.     ramsays@access.digex.com
  757.  
  758.   The TPU units can be used freely with in your programs.  If you want
  759.   the source code, more samples or swap-talk, just e-mail me.  I'll give
  760.   sample use-code for free.  Actual TPU-source code prices can be discussed.
  761.  
  762.    Scott D. Ramsay